package com.hainatong.jcmvvmbase.mainhome.fragment.warehouse;


import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.hainatong.jcmvvmbase.MvvmLazyFragment;
import com.hainatong.jcmvvmbase.R;
import com.hainatong.jcmvvmbase.databinding.FragmentLinyongRecordBinding;
import com.hainatong.jcmvvmbase.mainhome.adapter.EquipmentRecordAdapter;
import com.hainatong.jcmvvmbase.mainhome.adapter.WorkerRecordAdapter;
import com.hainatong.jcmvvmbase.mainhome.entity.WorkerEPMRecordBean;
import com.hainatong.mvvmbase.base.NoViewModel;
import com.scwang.smart.refresh.footer.ClassicsFooter;
import com.scwang.smart.refresh.header.ClassicsHeader;

import java.util.ArrayList;
import java.util.List;


public class LinYongRecordFragment extends MvvmLazyFragment<FragmentLinyongRecordBinding, NoViewModel>
{

    private WorkerRecordAdapter workerAdapter;
    private EquipmentRecordAdapter equipmentAdapter;


    @Override
    public int getLayoutId()
    {
        return R.layout.fragment_linyong_record;
    }

    @Override
    public int getBindingVariable()
    {
        return 0;
    }

    @Override
    protected void onRetryBtnClick()
    {
    }


    @Override
    protected void initView(View view)
    {
        workerAdapter = new WorkerRecordAdapter();
        equipmentAdapter = new EquipmentRecordAdapter();
        viewDataBinding.recyclerview.setLayoutManager( new LinearLayoutManager(getActivity()));
        viewDataBinding.recyclerview.setHasFixedSize(true);
        viewDataBinding.recyclerview.setAdapter( workerAdapter );

        workerAdapter.setOnItemClickListener( (adapter, view1, position) -> {



        } );
        viewDataBinding.refreshlayout.setRefreshHeader(new ClassicsHeader(getActivity()));
        viewDataBinding.refreshlayout.setRefreshFooter( new ClassicsFooter(getActivity()));
        viewDataBinding.refreshlayout.setOnRefreshListener(refreshLayout -> {

            viewDataBinding.refreshlayout.finishRefresh(true);

        });
        viewDataBinding.refreshlayout.setOnLoadMoreListener(refreshLayout -> {
            viewDataBinding.refreshlayout.finishLoadMore(true);
        });


    }

    @Override
    protected void lazyLoad()
    {
        List<WorkerEPMRecordBean> recordBeanList = new ArrayList<>();
        WorkerEPMRecordBean worker = new WorkerEPMRecordBean();
        worker.setName("包天下");
        worker.setDepartment("甲板部");
        worker.setJob("水手");
        worker.setEquipRecord("LLLLLLLLLL");
        worker.setLastTime("2020-01-01");
        worker.setStatus(2);
        recordBeanList.add(worker);
        recordBeanList.add(worker);
        recordBeanList.add(worker);
        recordBeanList.add(worker);
        recordBeanList.add(worker);
        recordBeanList.add(worker);
        workerAdapter.setList(recordBeanList);
        workerAdapter.notifyDataSetChanged();
    }
}
